import { HttpRequestConfig, HttpResponse, HttpTask } from 'luch-request';
export * from './login';
export type Custom = {
  /** @desc 是否显示错误toast */
  showErrorToast?: boolean;
  /** @desc 是否需要手动catch  默认为false */
  catch?: boolean;
  /** @desc 关闭全局mock时 当前请求是否需要单独mock */
  mock?: boolean;
};

/**
 * @desc 请求配置
 */
export interface CustomHttpRequestConfig extends HttpRequestConfig {
  custom?: Custom;
}

/**
 *  @desc 基础响应格式
 */
export interface ApiBaseResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

/**
 * @desc 请求返回值格式
 */
export interface HttpResponseWithError<T = any, D = HttpTask> extends HttpResponse<T, D> {
  error: boolean;
}

/**
 *  @desc POST 请求函数类型
 */
export type ApiPostFunction<P = Record<string, any>, R = any> = (
  data: P,
  config?: CustomHttpRequestConfig
) => Promise<HttpResponseWithError<ApiBaseResponse<R>, HttpTask>>;
